-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(resolve): support resolving TS files by JS extension specifiers in JS files #18889
base: main
Are you sure you want to change the base?
fix(resolve): support resolving TS files by JS extension specifiers in JS files #18889
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for researching that. This makes the implementation a lot simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! There were people asking on Vitest too vitest-dev/vitest#5999
/ecosystem-ci run |
commit: |
This comment was marked as outdated.
This comment was marked as outdated.
📝 Ran ecosystem CI on
✅ analogjs, astro, ladle, laravel, marko, previewjs, quasar, qwik, rakkas, storybook, sveltekit, unocss, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest, vuepress |
Description
In the past meeting, we decided to support
.js
->.ts
resolving in JS files based onmoduleResolution
. We thought that TS requiresmoduleResolution
to be set toNode16
or above at that time.But it seems TypeScript allows importing TS files by JS extension specifiers regardless of
moduleResolution
.https://stackblitz.com/edit/vitejs-vite-hvbhlg?file=tsconfig.json,sub1.ts,sub2.mts,main1.js&terminal=build
Surprisingly, this behavior seems to be there since TS 2.0 🫨(microsoft/TypeScript#8895, found the link in esbuild repo).
This PR allows the
.js
->.ts
resolving in JS files regardless ofmoduleResolution
.fixes #8993
refs #5510